from __future__ import absolute_import, unicode_literals
import os

import time
from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "meiduo1.settings.dev")

app = Celery('meiduo')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
#加载配置文件
app.config_from_object('celery_test.config', namespace='CELERY')

# Load task modules from all registered Django app configs.
#注册任务，模块中任务文件的路径
app.autodiscover_tasks(['celery_test.test.tasks','celery_test.email.tasks'])
# 启动celery ：celery -A celery_test.main worker -l info


# @app.task(bind=True,name='xixi')
# def debug_task(self,count):
#     for i in range(0,count):
#         time.sleep(1)
#         print(i)